package org.swingplus.core.scanner;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.swingplus.core.context.ApplicationContext;
import org.swingplus.core.util.AnnoManageUtil;

import java.lang.annotation.Annotation;
import java.util.Iterator;
import java.util.Map;

public class StyleScan {

    private static final Logger logger= LoggerFactory.getLogger(StyleScan.class);

	public static Annotation[] styleScan(String packageName,Class<?> clazz){
//    	AnnoManageUtil.getAnnotationType("",clazz);
        Annotation[] annotations =null;
        //System.out.println(annotations[0].annotationType().getName());
        Map<String, Object> createByAnnotationType = AnnoManageUtil.createByAnnotationType("",clazz);
        logger.info("discover Annotation: {} size: {} classpath: {}",clazz.getSimpleName(),createByAnnotationType.size(),clazz.getTypeName());
//        logger.info("discover Annotation: {} size: {}",clazz.getSimpleName(),createByAnnotationType.size());
        for (String key : createByAnnotationType.keySet()) {
            Object object = createByAnnotationType.get(key);
            ApplicationContext.setBean(key,object);
            logger.info("     set ApplicationContext: instanceName: {}, address: {}",key, object);
        }
        return annotations;

    }

}
